﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Text;
using System.Web.SessionState;

namespace jnlamp.Web.devinfo
{
    /// <summary>
    /// GetStatus 的摘要说明
    /// </summary>
    public class GetStatus : IHttpHandler, IRequiresSessionState
    {
        jnlamp.BLL.dbstatus bll = new jnlamp.BLL.dbstatus();       
        public void ProcessRequest(HttpContext context)
        {

            string ac = "";
            if (null != context.Request.Form["action"])
            {//获取前台传来的值  
                ac = context.Request.Form["action"].ToString().Trim();
            }
            else if (null != context.Request.QueryString["action"])
            {
                ac = context.Request.QueryString["action"].ToString().Trim();
            }

            if (ac == "query")
                Query(context);
            else if (ac == "getxqh")
                Queryxqh(context);//小气候参数
            else if (ac.StartsWith("XQH"))
                QueryXQH(context);//小气候数据
            else if (ac == "TSQ")
                QueryTSQ(context);//土壤墒情
            else if (ac == "HZTSQ")
                QueryHZTSQ(context);//土壤墒情
            else if (ac == "JBTSQ")
                QueryJBTSQ(context);//土壤墒情
            else if (ac == "HZYBQ")
                QueryHZYBQ(context);//土壤墒情
            else if (ac=="CBJ")
                QueryAll(context,"CBJ");//小气候数据
        }
        public void QueryAll(HttpContext context,string type)
        {
            context.Response.ContentType = "text/plain";
            int uid = Web.Admin.myinfo.getID(context);
            if (uid != 0)
            {
                string devID = "", StartTime = "", EndTime = "";

                if (null != context.Request.Form["devID"])
                {
                    devID = context.Request.Form["devID"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["devID"])
                {
                    devID = context.Request.QueryString["devID"].ToString().Trim();
                }
                if (null != context.Request.Form["StartTime"])
                {//获取前台传来的值  
                    StartTime = context.Request.Form["StartTime"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["StartTime"])
                {
                    StartTime = context.Request.QueryString["StartTime"].ToString().Trim();
                }
                if (null != context.Request.Form["EndTime"])
                {//获取前台传来的值  
                    EndTime = context.Request.Form["EndTime"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["EndTime"])
                {
                    EndTime = context.Request.QueryString["EndTime"].ToString().Trim();
                }
                //================================================================  
                //获取分页和排序信息：页大小，页码，排序方式，排序字段  
                int pageRows, page;
                pageRows = 10;
                page = 1;
                string order, sort, oderby; order = sort = oderby = "";
                if (null != context.Request.Form["rows"])
                {
                    pageRows = int.Parse(context.Request.Form["rows"].ToString().Trim());
                }
                else if (null != context.Request.QueryString["rows"])
                {
                    pageRows = int.Parse(context.Request.QueryString["rows"].ToString().Trim());
                }
                if (null != context.Request.Form["page"])
                {
                    page = int.Parse(context.Request.Form["page"].ToString().Trim());
                }
                else if (null != context.Request.QueryString["page"])
                {
                    page = int.Parse(context.Request.QueryString["page"].ToString().Trim());
                }
                if (null != context.Request.Form["sort"])
                {
                    order = context.Request.Form["sort"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["sort"])
                {
                    order = context.Request.QueryString["sort"].ToString().Trim();
                }
                if (null != context.Request.Form["order"])
                {
                    sort = context.Request.Form["order"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["order"])
                {
                    sort = context.Request.QueryString["order"].ToString().Trim();
                }
                StringBuilder strWhere = new StringBuilder();
                if (StartTime != "")
                {
                    strWhere.AppendFormat(" updateTime>='{0}' and ", StartTime);
                }
                if (EndTime != "")
                {
                    strWhere.AppendFormat(" updateTime<='{0}' and ", EndTime);
                }
                if (devID != "")
                {
                    strWhere.AppendFormat(" devID='{0}' and ", devID);
                }
                int startindex = strWhere.ToString().LastIndexOf("and");//获取最后一个and的位置  
                if (startindex >= 0)
                {
                    strWhere.Remove(startindex, 3);//删除多余的and关键字  
                }
                if (sort != "" && order != "")
                {
                    oderby = order + " " + sort;
                }                
                DataSet ds = bll.GetListByPage(type,strWhere.ToString(),oderby, (page - 1) * pageRows + 1, page * pageRows,"");
                int count = bll.GetRecordCount(type,strWhere.ToString(),"");//获取条数  
                string strJson = ToJson.Dataset2Json(ds, count);//DataSet数据转化为Json数据  
                context.Response.Write(strJson);//返回给前台页面  
                context.Response.End();
            }
            else
            {
                context.Response.Write("L");//返回给前台页面  
                context.Response.End();
            }
        }
        public void QueryHZYBQ(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int uid = Web.Admin.myinfo.getID(context);
            if (uid != 0)
            {
                string StartTime = "", EndTime = "";
                             
                if (null != context.Request.Form["StartTime"])
                {//获取前台传来的值  
                    StartTime = context.Request.Form["StartTime"].ToString().Trim();
                }
                if (null != context.Request.Form["EndTime"])
                {//获取前台传来的值  
                    EndTime = context.Request.Form["EndTime"].ToString().Trim();
                }
                //================================================================  
                //获取分页和排序信息：页大小，页码，排序方式，排序字段 
                
                StringBuilder strWhere = new StringBuilder();
                if (StartTime != "")
                {
                    strWhere.AppendFormat(" updateTime>='{0}' and ", StartTime);
                }
                if (EndTime != "")
                {
                    strWhere.AppendFormat(" updateTime<='{0}' and ", EndTime);
                }

                int startindex = strWhere.ToString().LastIndexOf("and");//获取最后一个and的位置  
                if (startindex >= 0)
                {
                    strWhere.Remove(startindex, 3);//删除多余的and关键字  
                }
                string sebm = "";
                if (null != context.Request.Form["sebm"])
                {
                    sebm = context.Request.Form["sebm"].ToString().Trim();
                }
                StringBuilder strWhere1 = new StringBuilder();
                
                if (sebm != "" && sebm != "0")
                {
                    if (sebm.Length == 6)
                    {

                        if (sebm.EndsWith("0000"))
                        {
                            strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm.Substring(0, 2));
                        }
                        else if (sebm.EndsWith("00"))
                        {
                            strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm.Substring(0, 4));
                        }
                        else
                        {
                            strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm);
                        }
                    }
                    else
                    {
                        strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm);
                    }
                }
                else
                {
                    string[] pcc = Web.Admin.myinfo.getPCC(context).Split(',');
                    string add = string.Join("", pcc);
                    strWhere1.AppendFormat(" DevLocation like '%{0}%' and ", add);

                }
                startindex = strWhere1.ToString().LastIndexOf("and");//获取最后一个and的位置  
                if (startindex >= 0)
                {
                    strWhere1.Remove(startindex, 3);//删除多余的and关键字  
                }
                DataSet ds = bll.HZYBQ(strWhere1.ToString(),strWhere.ToString());
                int count = 0;//获取条数  
                if (ds.Tables.Count > 0)
                    count = ds.Tables[0].Rows.Count;
                string strJson = ToJson.Dataset2Json(ds, count);//DataSet数据转化为Json数据  
                context.Response.Write(strJson);//返回给前台页面  
                context.Response.End();
            }
            else
            {
                context.Response.Write("L");//返回给前台页面  
                context.Response.End();

            }
        }
        public void QueryTSQ(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int uid = Web.Admin.myinfo.getID(context);
            if (uid != 0)
            {
                string devID = "", StartTime = "", EndTime = "";

                if (null != context.Request.Form["devID"])
                {
                    devID = context.Request.Form["devID"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["devID"])
                {
                    devID = context.Request.QueryString["devID"].ToString().Trim();
                }
                if (null != context.Request.Form["StartTime"])
                {//获取前台传来的值  
                    StartTime = context.Request.Form["StartTime"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["StartTime"])
                {
                    StartTime = context.Request.QueryString["StartTime"].ToString().Trim();
                }
                if (null != context.Request.Form["EndTime"])
                {//获取前台传来的值  
                    EndTime = context.Request.Form["EndTime"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["EndTime"])
                {
                    EndTime = context.Request.QueryString["EndTime"].ToString().Trim();
                }
                //================================================================  
                //获取分页和排序信息：页大小，页码，排序方式，排序字段  
                int pageRows, page;
                pageRows = 10;
                page = 1;
                string order, sort, oderby; order = sort = oderby = "";
                if (null != context.Request.Form["rows"])
                {
                    pageRows = int.Parse(context.Request.Form["rows"].ToString().Trim());
                }
                else if (null != context.Request.QueryString["rows"])
                {
                    pageRows = int.Parse(context.Request.QueryString["rows"].ToString().Trim());
                }
                if (null != context.Request.Form["page"])
                {
                    page = int.Parse(context.Request.Form["page"].ToString().Trim());
                }
                else if (null != context.Request.QueryString["page"])
                {
                    page = int.Parse(context.Request.QueryString["page"].ToString().Trim());
                }
                if (null != context.Request.Form["sort"])
                {
                    order = context.Request.Form["sort"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["sort"])
                {
                    order = context.Request.QueryString["sort"].ToString().Trim();
                }
                if (null != context.Request.Form["order"])
                {
                    sort = context.Request.Form["order"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["order"])
                {
                    sort = context.Request.QueryString["order"].ToString().Trim();
                }
                StringBuilder strWhere = new StringBuilder();
                if (StartTime != "")
                {
                    strWhere.AppendFormat(" datetime>='{0}' and ", StartTime);
                }
                if (EndTime != "")
                {
                    strWhere.AppendFormat(" datetime<='{0}' and ", EndTime);
                }
                
                int startindex = strWhere.ToString().LastIndexOf("and");//获取最后一个and的位置  
                if (startindex >= 0)
                {
                    strWhere.Remove(startindex, 3);//删除多余的and关键字  
                }
                if (sort != "" && order != "")
                {
                    oderby = order + " " + sort;
                }
                int count = 0;
                DataSet ds = bll.GetTSQ(devID, pageRows, page, strWhere.ToString(), out count);
                string strJson = ToJson.Dataset2Json(ds, count);//DataSet数据转化为Json数据  
                context.Response.Write(strJson);//返回给前台页面  
                context.Response.End();
            }
            else
            {
                context.Response.Write("L");//返回给前台页面  
                context.Response.End();
            }
        }
        public void QueryHZTSQ(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int uid = Web.Admin.myinfo.getID(context);
            if (uid != 0)
            {
                string  StartTime = "", EndTime = "";
                
                if (null != context.Request.Form["StartTime"])
                {//获取前台传来的值  
                    StartTime = context.Request.Form["StartTime"].ToString().Trim();
                }
                if (null != context.Request.Form["EndTime"])
                {//获取前台传来的值  
                    EndTime = context.Request.Form["EndTime"].ToString().Trim();
                }
                //================================================================  
                //获取分页和排序信息：页大小，页码，排序方式，排序字段 

                StringBuilder strWhere = new StringBuilder();
                if (StartTime != "")
                {
                    strWhere.AppendFormat(" datetime>='{0}' and ", StartTime);
                }
                if (EndTime != "")
                {
                    strWhere.AppendFormat(" datetime<='{0}' and ", EndTime);
                }

                int startindex = strWhere.ToString().LastIndexOf("and");//获取最后一个and的位置  
                if (startindex >= 0)
                {
                    strWhere.Remove(startindex, 3);//删除多余的and关键字  
                }
                string sebm = "";
                if (null != context.Request.Form["sebm"])
                {
                    sebm = context.Request.Form["sebm"].ToString().Trim();
                }
                StringBuilder strWhere1 = new StringBuilder();

                if (sebm != "" && sebm != "0")
                {
                    if (sebm.Length == 6)
                    {

                        if (sebm.EndsWith("0000"))
                        {
                            strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm.Substring(0, 2));
                        }
                        else if (sebm.EndsWith("00"))
                        {
                            strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm.Substring(0, 4));
                        }
                        else
                        {
                            strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm);
                        }
                    }
                    else
                    {
                        strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm);
                    }
                }
                else
                {
                    string[] pcc = Web.Admin.myinfo.getPCC(context).Split(',');
                    string add = string.Join("", pcc);
                    strWhere1.AppendFormat(" DevLocation like '%{0}%' and ", add);

                }
                startindex = strWhere1.ToString().LastIndexOf("and");//获取最后一个and的位置  
                if (startindex >= 0)
                {
                    strWhere1.Remove(startindex, 3);//删除多余的and关键字  
                }
                DataSet ds = bll.HZTSQ(strWhere1.ToString(), strWhere.ToString());
                int count = 0;//获取条数  
                if (ds.Tables.Count > 0)
                    count = ds.Tables[0].Rows.Count;
                string strJson = ToJson.Dataset2Json(ds, count);//DataSet数据转化为Json数据  
                context.Response.Write(strJson);//返回给前台页面  
                context.Response.End();
            }
            else
            {
                context.Response.Write("L");//返回给前台页面  
                context.Response.End();

            }
        }
        public void QueryJBTSQ(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int uid = Web.Admin.myinfo.getID(context);
            if (uid != 0)
            {
                string StartTime = "", EndTime = "";                
                if (null != context.Request.QueryString["StartTime"])
                {//获取前台传来的值  
                    StartTime = context.Request.QueryString["StartTime"].ToString().Trim();
                }
                if (null != context.Request.QueryString["EndTime"])
                {//获取前台传来的值  
                    EndTime = context.Request.QueryString["EndTime"].ToString().Trim();
                }
                //================================================================  
                //获取分页和排序信息：页大小，页码，排序方式，排序字段 

                StringBuilder strWhere = new StringBuilder();
                if (StartTime != "")
                {
                    strWhere.AppendFormat(" datetime>='{0}' and ", StartTime);
                }
                if (EndTime != "")
                {
                    strWhere.AppendFormat(" datetime<='{0}' and ", EndTime);
                }

                int startindex = strWhere.ToString().LastIndexOf("and");//获取最后一个and的位置  
                if (startindex >= 0)
                {
                    strWhere.Remove(startindex, 3);//删除多余的and关键字  
                }
                string sebm = "";
                if (null != context.Request.QueryString["sebm"])
                {
                    sebm = context.Request.QueryString["sebm"].ToString().Trim();
                }
                StringBuilder strWhere1 = new StringBuilder();

                if (sebm != "" && sebm != "0")
                {
                    if (sebm.Length == 6)
                    {

                        if (sebm.EndsWith("0000"))
                        {
                            strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm.Substring(0, 2));
                        }
                        else if (sebm.EndsWith("00"))
                        {
                            strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm.Substring(0, 4));
                        }
                        else
                        {
                            strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm);
                        }
                    }
                    else
                    {
                        strWhere1.AppendFormat(" DevOwnerID like '{0}%' and ", sebm);
                    }
                }
                else
                {
                    string[] pcc = Web.Admin.myinfo.getPCC(context).Split(',');
                    string add = string.Join("", pcc);
                    strWhere1.AppendFormat(" DevLocation like '%{0}%' and ", add);

                }
                startindex = strWhere1.ToString().LastIndexOf("and");//获取最后一个and的位置  
                if (startindex >= 0)
                {
                    strWhere1.Remove(startindex, 3);//删除多余的and关键字  
                }
                decimal avgwd = 0, sumyl = 0;
                bll.JBTSQ(strWhere1.ToString(), strWhere.ToString(),out avgwd,out sumyl);
                string json = "[{\"avgwd\":\"" + avgwd + "\",\"sumyl\":\"" + sumyl + "\"}]";
                context.Response.Write(json);//返回给前台页面  
                context.Response.End();
            }
            else
            {
                context.Response.Write("L");//返回给前台页面  
                context.Response.End();

            }
        }
        public void Query(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int uid = Web.Admin.myinfo.getID(context);
            if (uid != 0)
            {
                string type = "", StartTime = "", EndTime = "", devID="",avg="";
                type = "";
                if (null != context.Request.Form["type"])
                {
                    type = context.Request.Form["type"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["type"])
                {
                    type = context.Request.QueryString["type"].ToString().Trim();
                }
                if (null != context.Request.Form["avg"])
                {
                    avg = context.Request.Form["avg"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["avg"])
                {
                    avg = context.Request.QueryString["avg"].ToString().Trim();
                }
                if (null != context.Request.Form["devID"])
                {
                    devID = context.Request.Form["devID"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["devID"])
                {
                    devID = context.Request.QueryString["devID"].ToString().Trim();
                }
                if (null != context.Request.Form["StartTime"])
                {//获取前台传来的值  
                    StartTime = context.Request.Form["StartTime"].ToString().Trim();
                }
                if (null != context.Request.Form["EndTime"])
                {//获取前台传来的值  
                    EndTime = context.Request.Form["EndTime"].ToString().Trim();
                }
                //================================================================  
                //获取分页和排序信息：页大小，页码，排序方式，排序字段  
                int pageRows, page;
                pageRows = 10;
                page = 1;
                string order, sort, oderby; order = sort = oderby = "";
                if (null != context.Request.Form["rows"])
                {
                    pageRows = int.Parse(context.Request.Form["rows"].ToString().Trim());
                }
                if (null != context.Request.Form["page"])
                {
                    page = int.Parse(context.Request.Form["page"].ToString().Trim());
                }
                if (null != context.Request.Form["sort"])
                {
                    order = context.Request.Form["sort"].ToString().Trim();
                }
                if (null != context.Request.Form["order"])
                {
                    sort = context.Request.Form["order"].ToString().Trim();
                }                
                StringBuilder strWhere = new StringBuilder();
                if (StartTime != "")
                {
                    strWhere.AppendFormat(" updateTime>='{0}' and ", StartTime);
                }
                if (EndTime != "")
                {
                    strWhere.AppendFormat(" updateTime<='{0}' and ", EndTime);
                }
                if (devID != "")
                {
                    strWhere.AppendFormat(" devID='{0}' and ", devID);
                }
                int startindex = strWhere.ToString().LastIndexOf("and");//获取最后一个and的位置  
                if (startindex >= 0)
                {
                    strWhere.Remove(startindex, 3);//删除多余的and关键字  
                }
                if (sort != "" && order != "")
                {
                    oderby = order + " " + sort;
                }
                DataSet ds = bll.GetListByPage(type,strWhere.ToString(), oderby, (page - 1) * pageRows + 1, page * pageRows,avg);
                int count = bll.GetRecordCount(type,strWhere.ToString(),avg);//获取条数  
                string strJson = ToJson.Dataset2Json(ds, count);//DataSet数据转化为Json数据  
                context.Response.Write(strJson);//返回给前台页面  
                context.Response.End();
            }
            else
            {
                context.Response.Write("L");//返回给前台页面  
                context.Response.End();

            }
        }
        public void QueryXQH(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int uid = Web.Admin.myinfo.getID(context);
            if (uid != 0)
            {
                string devID = "", StartTime = "", EndTime = "",ac="";
                if (null != context.Request.QueryString["action"])
                {
                    ac = context.Request.QueryString["action"].ToString().Trim();
                }
                if (null != context.Request.Form["devID"])
                {
                    devID = context.Request.Form["devID"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["devID"])
                {
                    devID = context.Request.QueryString["devID"].ToString().Trim();
                }
                if (null != context.Request.Form["StartTime"])
                {//获取前台传来的值  
                    StartTime = context.Request.Form["StartTime"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["StartTime"])
                {
                    StartTime = context.Request.QueryString["StartTime"].ToString().Trim();
                }
                if (null != context.Request.Form["EndTime"])
                {//获取前台传来的值  
                    EndTime = context.Request.Form["EndTime"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["EndTime"])
                {
                    EndTime = context.Request.QueryString["EndTime"].ToString().Trim();
                }
                //================================================================  
                //获取分页和排序信息：页大小，页码，排序方式，排序字段  
                int pageRows, page;
                pageRows = 10;
                page = 1;
                string order, sort, oderby; order = sort = oderby = "";
                if (null != context.Request.Form["rows"])
                {
                    pageRows = int.Parse(context.Request.Form["rows"].ToString().Trim());
                }
                else if (null != context.Request.QueryString["rows"])
                {
                    pageRows = int.Parse(context.Request.QueryString["rows"].ToString().Trim());
                }
                if (null != context.Request.Form["page"])
                {
                    page = int.Parse(context.Request.Form["page"].ToString().Trim());
                }
                else if (null != context.Request.QueryString["page"])
                {
                    page = int.Parse(context.Request.QueryString["page"].ToString().Trim());
                }
                if (null != context.Request.Form["sort"])
                {
                    order = context.Request.Form["sort"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["sort"])
                {
                    order = context.Request.QueryString["sort"].ToString().Trim();
                }
                if (null != context.Request.Form["order"])
                {
                    sort = context.Request.Form["order"].ToString().Trim();
                }
                else if (null != context.Request.QueryString["order"])
                {
                    sort = context.Request.QueryString["order"].ToString().Trim();
                }
                StringBuilder strWhere = new StringBuilder();
                if (StartTime != "")
                {
                    strWhere.AppendFormat(" datetime>='{0}' and ", StartTime);
                }
                if (EndTime != "")
                {
                    strWhere.AppendFormat(" datetime<='{0}' and ", EndTime);
                }

                int startindex = strWhere.ToString().LastIndexOf("and");//获取最后一个and的位置  
                if (startindex >= 0)
                {
                    strWhere.Remove(startindex, 3);//删除多余的and关键字  
                }
                if (sort != "" && order != "")
                {
                    oderby = order + " " + sort;
                }
                int count = 0;
                DataSet ds=null;
                if (devID != "")
                {
                    if (ac == "XQH")
                        ds = bll.GetXQH(devID, pageRows, page, strWhere.ToString(), out count, "");
                    else if (ac == "XQHA")
                        ds = bll.GetXQH(devID, pageRows, page, strWhere.ToString(), out count, "A");
                    else if (ac == "XQHM")
                        ds = bll.GetXQH(devID, pageRows, page, strWhere.ToString(), out count, "M");
                    string strJson = ToJson.Dataset2Json(ds, count);//DataSet数据转化为Json数据  
                    context.Response.Write(strJson);//返回给前台页面
                }
                context.Response.End();
            }
            else
            {
                context.Response.Write("L");//返回给前台页面  
                context.Response.End();

            }
        }
        public void Queryxqh(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int uid = Web.Admin.myinfo.getID(context);
            if (uid != 0)
            {
                string xqhid = "";

                //获取前台传来的值 
                if (null != context.Request.QueryString["XQHID"])
                {//获取前台传来的值  
                    xqhid = context.Request.QueryString["XQHID"].ToString().Trim();
                }
                string XQHID = bll.GetPhnum(xqhid);

                context.Response.Write("{\"XQHID\":\"" + XQHID + "\"}");//返回给前台页面  
                context.Response.End();
            }
            else
            {
                context.Response.Write("L");//返回给前台页面  
                context.Response.End();

            }
        }  
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}